<template>
	<view class="container">

		<view class="user-info" @click="getUserInfo">
			<image class="avatar" src="../../static/img/Grua.jpg"></image>
			<view class="text-container">
				<text class="realname">{{ realname ? realname : '请完善个人资料' }}</text>
				<text class="username">{{repairId === 0 ? '用户':'维修者'}}</text>
			</view>
			<uni-icons type="right" size="20" color="#333"></uni-icons>
		</view>

		<view class="features">
			<view class="feature-item" @click="getPending">
				<uni-icons type="compose" size="30" color="#333"></uni-icons>
				<text class="label">待处理</text>
			</view>
			<view class="feature-item" @click="getFinish">
				<uni-icons type="checkbox" size="30" color="#333"></uni-icons>
				<text class="label">已完成</text>
			</view>
			<view class="feature-item" @click="getMyRepair">
				<uni-icons type="list" size="30" color="#333"></uni-icons>
				<text class="label">我的维修单</text>
			</view>
		</view>

		<view class="menu">
			<view class="menu-item" @click="UseInfo">
				<uni-icons type="help" size="20" color="#333"></uni-icons>
				<text class="label">使用说明</text>
				<uni-icons type="right" size="10" color="#333" class="icon1"></uni-icons>
			</view>
			<view class="menu-item" @click="updateLog">
				<uni-icons type="compose" size="20" color="#333"></uni-icons>
				<text class="label">更新日志</text>
				<uni-icons type="right" size="10" color="#333" class="icon1"></uni-icons>
			</view>
			<view class="menu-item" @click="aboutUs">
				<uni-icons type="info" size="20" color="#333"></uni-icons>
				<text class="label">关于我们</text>
				<uni-icons type="right" size="10" color="#333" class="icon1"></uni-icons>
			</view>
		</view>

		<view class="logout-btn" @click="logOut">退出登录</view>

	</view>
</template>

<script>
	import "../../common/css/my.scss"
	import uniIcons from '../../uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
	import API from "../../api/api"
	export default {
		components: {
			uniIcons
		},
		data() {
			return {
				realname: '',
				repairId: ''
			}
		},
		methods: {
			getUserInfo() {
				uni.navigateTo({
					url: '/pages/user-info/user-info'
				})
			},
			getPending() {
				uni.navigateTo({
					url: '/pages/My/component/Pending?tabId=2'
				})
			},
			getFinish() {
				uni.navigateTo({
					url: '/pages/My/component/Pending?tabId=4'
				})
			},
			getMyRepair() {
				uni.navigateTo({
					url: '/pages/My/component/Pending?tabId=1'
				})
			},
			aboutUs() {
				uni.navigateTo({
					url: '/pages/My/component/AboutUs'
				})
			},
			updateLog() {
				uni.navigateTo({
					url: '/pages/My/component/UpdateNote'
				})
			},
			UseInfo() {
				uni.navigateTo({
					url: '/pages/My/component/UseInfo'
				})
			},
			logOut() {
				uni.removeStorageSync('token');
				uni.navigateTo({
					url: '/pages/login/login'
				})
			},
			async getUser() {
				let token = uni.getStorageSync("token")
				let res = await API.getUserInfo(token)
				// console.log(res.data)
				this.realname = res.data.realname
				this.repairId = res.data.repairId
			}
		},
		onLoad() {
			this.getUser()
		}
	}
</script>

<style>

</style>